package com.moody.web;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.*;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.moody.hibernate.domain.CodeLib;
import com.moody.hibernate.domain.CustInfo;
import com.moody.hibernate.domain.GuarantorInfo;
import com.moody.hibernate.domain.ModelHis;
import com.moody.hibernate.domain.RoleInfo;
import com.moody.hibernate.domain.UserInfo;
import com.moody.hibernate.domain.UserRole;
import com.moody.init.Collateral;
import com.moody.init.Country;
import com.moody.init.DataDictionary;
import com.moody.init.DataLib;
import com.moody.init.Debt;
import com.moody.init.Guaranty;
import com.moody.init.Industry;
import com.moody.init.ParamModelInit;
import com.moody.init.Region;
import com.moody.init.ReportModelInit;
import com.moody.service.CustomerService;
import com.moody.service.ModelService;
import com.moody.service.ObligationService;
import com.moody.service.SystemService;

/*
 * Copyright © Moody analytics
 *
 * @Author: Yan Jian
 * @Time: 2011-9-15 上午10:43:35
 * @Modified by: 
 * @Description: 级联下拉列表
 */

@Controller
@RequestMapping("/")
public class CascadingController {
	@Resource
	private CustomerService customerService;
	@Resource
	private ModelService modelService;
	@Resource
	private ObligationService obligationService;
	@Resource
	private SystemService systemService;
	
	//行业二级级联
	@RequestMapping("/industryCascading")
	public void industryCascading(HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		
		 response.setContentType("application/json; charset=utf-8");  
		 response.setHeader("Cache-Control", "no-cache");  
		 
		 PrintWriter out = response.getWriter();
		 
		 String industryParent = request.getParameter("industryParent");
			
		 Map<String, String> industryChildMap = new LinkedHashMap<String, String>();
		 industryChildMap = Industry.getInstance().getIndustryTree().get(industryParent);
		 
		 JSONObject jo=JSONObject.fromObject(industryChildMap); 
		 out.print(jo);
	}
	
	//城市级联
	@RequestMapping("/cityCascading")
	public void cityCascading(HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		
		 response.setContentType("application/json; charset=utf-8");  
		 response.setHeader("Cache-Control", "no-cache");  
		 
		 PrintWriter out = response.getWriter();
		 
		 String provinceCode = request.getParameter("provinceCode");
			
		 Map<String, String> cityMap = new LinkedHashMap<String, String>();
		 cityMap = Region.getInstance().getCity().get(provinceCode);
		 
		 JSONObject jo=JSONObject.fromObject(cityMap); 
		 out.print(jo);
	}
	
	@RequestMapping("/showCountry")
	public void showCountry(HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		
		 response.setContentType("application/json; charset=utf-8");  
		 response.setHeader("Cache-Control", "no-cache");  
		 
		 PrintWriter out = response.getWriter();
		 
		
		 out.print(Country.getInstance().getCountryJSON());
	}
	
	@RequestMapping("/showProvince")
	public void showProvince(HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		
		JSONArray jo = JSONArray.fromObject(Region.getInstance().getCityJSON());
		 response.setContentType("application/json; charset=utf-8");  
		 response.setHeader("Cache-Control", "no-cache");  
		 
		 PrintWriter out = response.getWriter();
		 
		
		 out.print(jo);
	}
	
	@SuppressWarnings("unchecked")
	@RequestMapping("/showCity")
	public void showCity(HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		Map<String,Object> cityMap = new LinkedHashMap<String,Object>();
		cityMap=Region.getInstance().getCityMap();
		List<Map<String,String>> cityList = new ArrayList<Map<String,String>>();

		String provinceId = request.getParameter("provinceId");
		
		cityList=(List<Map<String, String>>) cityMap.get(provinceId);
		
		JSONArray jo = JSONArray.fromObject(cityList);
		 response.setContentType("application/json; charset=utf-8");  
		 response.setHeader("Cache-Control", "no-cache");  
		 
		 PrintWriter out = response.getWriter();
		 
		
		 out.print(jo);
	}
	
	@SuppressWarnings("unchecked")
	@RequestMapping("/showUser")
	public void showUser(HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		String orgCode = request.getParameter("orgCode");
		String userId = request.getParameter("userId");
		List<Map<String,String>> userList = new ArrayList<Map<String,String>>();
		Map<String,String> condition = new LinkedHashMap<String,String>();
		condition.put("belongorg", orgCode);
		List<UserInfo> userInfoList = systemService.findUserByCondition(condition);
		
		for(UserInfo user : userInfoList){
			//是否是客户经理
			Boolean flag = false;
			List<UserRole> userRoleList = systemService.findUserRoleByUserId(user.getUserId());
			for(UserRole userRole : userRoleList){
				RoleInfo role = systemService.findRoleById(userRole.getId().getRoleId());
				if(role.getRoleName().contains("客户经理")){
					flag = true;
				}
			}
			
			if(flag){
				Map<String,String> map = new HashMap<String,String>();
				map.put("userCode", user.getUserId());
				map.put("userName", user.getUsername());
				userList.add(map);
			}
		}
		
		JSONArray jo = JSONArray.fromObject(userList);
		response.setContentType("application/json; charset=utf-8");  
		response.setHeader("Cache-Control", "no-cache");  
		 
		PrintWriter out = response.getWriter();
		out.print(jo);
	}
	
	@RequestMapping("/showIndustryTypeLevelOne")
	public void showIndustryTypeLevelOne(HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		LinkedList<LinkedHashMap<String, String>> industryLevelOneList = Industry.getInstance().getIndustryLevelOne();
		JSONArray jo = JSONArray.fromObject(industryLevelOneList);
		
		response.setContentType("application/json; charset=utf-8");  
		response.setHeader("Cache-Control", "no-cache");  
		PrintWriter out = response.getWriter();
		out.print(jo);
	}
	
	@RequestMapping("/showIndustryTypeLevelTwo")
	public void showshowIndustryTypeLevelTwo(HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		String levelOneId = request.getParameter("LevelOneId");
		List<Map<String, String>> levelTwo = null;
		if(levelOneId != null && !levelOneId.equals("")) levelTwo = Industry.getInstance().getIndustryLevelTwo(levelOneId.substring(0, 1));
		
		
		JSONArray jo = JSONArray.fromObject(levelTwo);
		response.setContentType("application/json; charset=utf-8");  
		response.setHeader("Cache-Control", "no-cache");  
		 
		PrintWriter out = response.getWriter();
		out.print(jo);
		
	}
	
	@RequestMapping("/showGuarantyTypeLevelOne")
	public void showGuarantyTypeLevelOne(HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		LinkedList<LinkedHashMap<String, String>> guarantyLevelOneList = Guaranty.getInstance().getGuarantyLevelOne();
		JSONArray jo = JSONArray.fromObject(guarantyLevelOneList);
		
		response.setContentType("application/json; charset=utf-8");  
		response.setHeader("Cache-Control", "no-cache");  
		PrintWriter out = response.getWriter();
		out.print(jo);
	}
	
	@RequestMapping("/showGuarantyTypeLevelTwo")
	public void showGuarantyTypeLevelTwo(HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		String levelOneId = request.getParameter("LevelOneId");
		List<Map<String, String>> levelTwo = Guaranty.getInstance().getGuarantyLevelTwo(levelOneId);
		
		JSONArray jo = JSONArray.fromObject(levelTwo);
		response.setContentType("application/json; charset=utf-8");  
		response.setHeader("Cache-Control", "no-cache");  
		 
		PrintWriter out = response.getWriter();
		out.print(jo);
		
	}
	
	@SuppressWarnings("unchecked")
	@RequestMapping("/showType")
	public void showAddType(HttpServletRequest request,
			HttpServletResponse response, String type) throws IOException{
		
		List<Map<String,String>> addTypeList = new ArrayList<Map<String,String>>();

		addTypeList=DataLib.getInstance().getListByType(type);
		
		if(type.equals("PDValue")){//对列表排序：
			Map<String,CodeLib> PDValueMap = DataDictionary.getInstance().getDataDictionary().get("PDValue");
			int point = 0;
			int location = 0;
			Map<String,String> temp = null;
			while(point < addTypeList.size()){
				location = Integer.parseInt(PDValueMap.get(addTypeList.get(point).get("code")).getItemDesc()) - 1;
				while(location != point){
					temp = addTypeList.get(location);
					addTypeList.set(location, addTypeList.get(point));
					addTypeList.set(point, temp);
					location = Integer.parseInt(PDValueMap.get(addTypeList.get(point).get("code")).getItemDesc()) - 1; //该条应该在的位置
				}
				point++;
				
			}
			
		}
		else if(type.equals("ExposureType")){//踢出大类
			Iterator<Map<String,String>> it = addTypeList.iterator();
			while(it.hasNext()){
				Map<String,String> temp = it.next();
				String code = temp.get("code");
				if(code.equals("02")||code.equals("03")||code.equals("04")||code.equals("06"))it.remove();
			}
		}
		else if(type.equals("PhaseStat")){
			 Iterator<Map<String,String>> it = addTypeList.iterator();
			 while(it.hasNext()){
				 Map<String,String> temp = it.next();
				 String code = temp.get("code");
				 if(code.equals("08")) it.remove();
			 }
		 }
		else if(type.equals("FTPParam")){
			List<CodeLib> ftpList = ParamModelInit.getInstance().getFTPParams();
			addTypeList = new ArrayList<Map<String,String>>();
			for(CodeLib item : ftpList){
				Map<String,String> map = new LinkedHashMap<String,String>();
				map.put("code", item.getId().getItemNo());
				map.put("name", item.getItemName());
				addTypeList.add(map);
			}
		}
		JSONArray jo = JSONArray.fromObject(addTypeList);
		response.setContentType("application/json; charset=utf-8");  
		response.setHeader("Cache-Control", "no-cache");  
		 
		 PrintWriter out = response.getWriter();
		 
		 
		
		 out.print(jo);
	}
	
	@SuppressWarnings("unchecked")
	@RequestMapping("/showLeverParamType")
	public void showLeverParamType(HttpServletRequest request,
			HttpServletResponse response, String type) throws IOException{
		
		List<Map<String,String>> addTypeList = new ArrayList<Map<String,String>>();

		addTypeList=DataLib.getInstance().getListByType(type);
		String custId = request.getSession().getAttribute("custLimitCustId").toString();
		CustInfo custInfo = customerService.findCustByCustId(custId);
		String creditLevel = custInfo.getCreditLevel();
		
		List<Map<String,String>> resultList = new ArrayList<Map<String,String>>();
		if(creditLevel != null && !creditLevel.equals("")){
			for(Map map : addTypeList){
				if(map.get("code").equals(creditLevel)){
					resultList.add(map);
				}
			}
		}else{
			resultList = addTypeList;
		}
	
		JSONArray jo = JSONArray.fromObject(resultList);
		response.setContentType("application/json; charset=utf-8");  
		response.setHeader("Cache-Control", "no-cache");  
		 
		 PrintWriter out = response.getWriter();
		 
		
		 out.print(jo);
	}
	
	@SuppressWarnings("unchecked")
	@RequestMapping("/showIndustryParamType")
	public void showIndustryParamType(HttpServletRequest request,
			HttpServletResponse response, String type) throws IOException{
		
		List<Map<String,String>> addTypeList = new ArrayList<Map<String,String>>();

		addTypeList=DataLib.getInstance().getListByType(type);

		String custId = request.getSession().getAttribute("custLimitCustId").toString();
		CustInfo custInfo = customerService.findCustByCustId(custId);
		String industryType = custInfo.getIndustryType();
		List<Map<String,String>> resultList = new ArrayList<Map<String,String>>();
		if(industryType != null && !industryType.equals("")){
			for(Map map : addTypeList){
				if(industryType.startsWith(map.get("code").toString())){
					resultList.add(map);
				}
			}
		}else{
			resultList = addTypeList;
		}
		
		JSONArray jo = JSONArray.fromObject(resultList);
		response.setContentType("application/json; charset=utf-8");  
		response.setHeader("Cache-Control", "no-cache");  
		 
		 PrintWriter out = response.getWriter();
		 
		
		 out.print(jo);
	}
	
	@SuppressWarnings("unchecked")
	@RequestMapping("/showCustList")
	public void showCustList(HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		 
		response.setContentType("application/json; charset=utf-8");  
		response.setHeader("Cache-Control", "no-cache");
		List<Map<String,String>> addTypeList = new ArrayList<Map<String,String>>();
		
		UserInfo user = (UserInfo) request.getSession().getAttribute("logonUser");
		String userId = user.getUserId();
		String orgId = user.getBelongorg();
		
		List<CustInfo> custList = customerService.findAllByCustType("", userId, orgId);
		for(CustInfo ci : custList){
			Map<String, String> addTypeMap = new LinkedHashMap<String, String>();
	    	addTypeMap.put("code", ci.getCustId());
	    	addTypeMap.put("name", ci.getCustName());
	    	addTypeList.add(addTypeMap);  
		}
		JSONArray jo = JSONArray.fromObject(addTypeList);
		PrintWriter out = response.getWriter();
		out.print(jo);
	}
	
	@SuppressWarnings("unchecked")
	@RequestMapping("/showGuarantorList")
	public void showGuarantorList(HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		 
		response.setContentType("application/json; charset=utf-8");  
		response.setHeader("Cache-Control", "no-cache");
		List<Map<String,String>> addTypeList = new ArrayList<Map<String,String>>();
		
		UserInfo user = (UserInfo) request.getSession().getAttribute("logonUser");
		String userId = user.getUserId();
		String orgId = user.getBelongorg();
		
		List<GuarantorInfo> custList = obligationService.findAllGuarantor();
		for(GuarantorInfo gi : custList){
			Map<String, String> addTypeMap = new LinkedHashMap<String, String>();
	    	addTypeMap.put("code", gi.getGuarantorId());
	    	addTypeMap.put("name", gi.getCustName());
	    	addTypeList.add(addTypeMap);  
		}
		JSONArray jo = JSONArray.fromObject(addTypeList);
		PrintWriter out = response.getWriter();
		out.print(jo);
	}
	
	@RequestMapping("/showColTypeLevelOne")
	public void showColTypeLevelOne(HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		
		List cTypeLevelOne = Collateral.getInstance().getFirstLevel();
		
		JSONArray jo = JSONArray.fromObject(cTypeLevelOne);
		 response.setContentType("application/json; charset=utf-8");  
		 response.setHeader("Cache-Control", "no-cache");  
		 
		 PrintWriter out = response.getWriter();
		 
		
		 out.print(jo);
	}
	
	@RequestMapping("/showColTypeLevelTwo")
	public void showColTypeLevelTwo(HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		
		Map cTypeMap = new HashMap();
		List levelTwoList = new ArrayList();
		
		cTypeMap = Collateral.getInstance().getSecondLevel();
		
		String levelOneCode = request.getParameter("levelOneCode");
		
		levelTwoList = (List) cTypeMap.get(levelOneCode);
		
		JSONArray jo = JSONArray.fromObject(levelTwoList);
		 response.setContentType("application/json; charset=utf-8");  
		 response.setHeader("Cache-Control", "no-cache");  
		 
		 PrintWriter out = response.getWriter();
		 
		
		 out.print(jo);
	}
	
	@RequestMapping("/showDebtTypeLevelOne")
	public void showDebtTypeLevelOne(HttpServletRequest request,HttpServletResponse response) throws IOException{
		List<Map<String,String>> debtTypeLevelOne = Debt.getInstance().getDebtTypeLevelOne();
		JSONArray jo = JSONArray.fromObject(debtTypeLevelOne);
		response.setContentType("application/json; charset=utf-8");  
		response.setHeader("Cache-Control", "no-cache");  
		 
		PrintWriter out = response.getWriter();
		out.print(jo);
			
	}
	
	@RequestMapping("/showDebtTypeLevelTwo")
	public void showDebtTypeLevelTwo(HttpServletRequest request,HttpServletResponse response) throws IOException{
		String levelOneCode = request.getParameter("levelOneCode");
		List<Map<String, String>> levelTwoList = Debt.getInstance().getDebtTypeLevelTwo(levelOneCode);
		JSONArray jo = JSONArray.fromObject(levelTwoList);
		response.setContentType("application/json; charset=utf-8");  
		response.setHeader("Cache-Control", "no-cache");  
		 
		PrintWriter out = response.getWriter();
		out.print(jo);
	}
	@RequestMapping("/showAllDebtType")
	public void showAllDebtType(HttpServletRequest request,HttpServletResponse response) throws IOException{
		List<Map<String,String>> debtType = Debt.getInstance().getDebtType();
		JSONArray jo = JSONArray.fromObject(debtType);
		response.setContentType("application/json; charset=utf-8");  
		response.setHeader("Cache-Control", "no-cache");  
		 
		PrintWriter out = response.getWriter();
		out.print(jo);
			
	}
	
	@RequestMapping("/showComboTree")
	public void showComboTree(HttpServletRequest request,
			HttpServletResponse response) throws IOException{

		/*response.setContentType("application/json; charset=utf-8");  
		response.setHeader("Cache-Control", "no-cache"); */
		
		StringBuffer strb = new StringBuffer("");
		strb.append("[");
		strb.append("{id:'01',text:'01',children:[ {id:'01-01',text:'01-01',leaf:true},{id:'01-02',text:'01-02',children:[{id:'01-02-01',text:'01-02-01',leaf:true},{id:'01-02-02',text:'01-02-02',leaf:true}]},{id:'01-03',text:'01-03',leaf:true}]},{id:'02',text:'02',leaf:true}");
		strb.append("]");
		
		response.setContentType("text/html;charset=utf-8");
		response.getWriter().write(strb.toString());

		
	}
	
	@RequestMapping("/showExposureType")
	public void showExposureType(HttpServletRequest request,
			HttpServletResponse response) throws IOException{

		Map extTypeMap = new HashMap();
		List<Map> resultList = new ArrayList<Map>();
		
		extTypeMap = DataDictionary.getInstance().getDataDictionary().get("ExposureType");
		
		Iterator iter = extTypeMap.entrySet().iterator(); 
		while (iter.hasNext()) { 
		    Map.Entry entry = (Map.Entry) iter.next(); 
		    String levelCode = (String) entry.getKey(); 
		    String levelName = ((CodeLib)entry.getValue()).getItemName();
		    if (levelCode.length() == 2){
		    	 if(levelCode.equals("01") || levelCode.equals("05") ){
		    		 Map<String, Object> levelMap = new HashMap<String, Object>();
		    		 levelMap.put("id", levelCode);
		    		 levelMap.put("text", levelName);
		    		 levelMap.put("leaf", true);
		    		 resultList.add(levelMap);
				  }
		    	 else if(levelCode.equals("02") || levelCode.equals("03") || levelCode.equals("04")  || levelCode.equals("06")){
		    		 Map<String, Object> levelOneMap = new HashMap<String, Object>();
					 levelOneMap.put("id", levelCode);
					 levelOneMap.put("text", levelName);
					 levelOneMap.put("leaf", false);
					 levelOneMap.put("children", new ArrayList());
					 resultList.add(levelOneMap);
		    	 }
		    	
		    }
		    else if(levelCode.length() == 4){
		    	
		    	String levelOneCode = levelCode.substring(0, 2);
		    	
		    	Map<String, Object> levelTwoMap = new HashMap<String, Object>();
		    	levelTwoMap.put("id", levelCode);
		    	levelTwoMap.put("text", levelName);
		    	levelTwoMap.put("leaf", true);
		    	
		    	for(Map m: resultList){
		    		if(m.get("id").equals(levelOneCode)){
		    			 ((ArrayList)m.get("children")).add(levelTwoMap);
		    		}
		    	}
		    }
		}
		
		JSONArray JA = JSONArray.fromObject(resultList);
		
		response.setContentType("application/json; charset=utf-8");  
		response.setHeader("Cache-Control", "no-cache"); 
		response.getWriter().print(JA);

		
	}
	
	@RequestMapping("/showIndexItem")
	public void showIndexItem(HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		
		List<Map> resultList = new ArrayList<Map>();
		
		resultList = ReportModelInit.getInstance().getEnterFinancialIndexItemFromModel();
		
		JSONArray JA = JSONArray.fromObject(resultList);
		
		response.setContentType("application/json; charset=utf-8");  
		response.setHeader("Cache-Control", "no-cache"); 
		response.getWriter().print(JA);
	}
	
	
	@SuppressWarnings("unchecked")
	@RequestMapping("/showPDModelList")
	public void showPDModelList(HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		 
		response.setContentType("application/json; charset=utf-8");  
		response.setHeader("Cache-Control", "no-cache");
		String custType = (String) request.getParameter("custType");
		List<Map<String,String>> addTypeList = new ArrayList<Map<String,String>>();
		
		List<ModelHis> modelList = modelService.findEffectedModelHis();
		Iterator it = modelList.iterator();
		while(it.hasNext()){
			if(custType == null || custType.equals(""))break;
			ModelHis model = (ModelHis) it.next();
			if(custType.equals("04") && model.getModelKind1().equals("04") || !custType.equals("04") && !model.getModelKind1().equals("04"));
			else it.remove();
		}
		for(ModelHis mh : modelList){
			Map<String, String> addTypeMap = new LinkedHashMap<String, String>();
	    	addTypeMap.put("code", mh.getModelId());
	    	addTypeMap.put("name", mh.getModelName());
	    	addTypeList.add(addTypeMap);  
		}
		JSONArray jo = JSONArray.fromObject(addTypeList);
		PrintWriter out = response.getWriter();
		out.print(jo);
	}
	
	@SuppressWarnings("unchecked")
	@RequestMapping("/showPDModelListRetail")
	public void showPDModelListRetail(HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		 
		response.setContentType("application/json; charset=utf-8");  
		response.setHeader("Cache-Control", "no-cache");
		List<Map<String,String>> addTypeList = new ArrayList<Map<String,String>>();
		
		List<ModelHis> modelList = modelService.findEffectedModelHis();
		for(ModelHis mh : modelList){
			if(mh.getModelName().contains("零售客户")){
				Map<String, String> addTypeMap = new LinkedHashMap<String, String>();
		    	addTypeMap.put("code", mh.getModelId());
		    	addTypeMap.put("name", mh.getModelName());
		    	addTypeList.add(addTypeMap);
			}
		}
		JSONArray jo = JSONArray.fromObject(addTypeList);
		PrintWriter out = response.getWriter();
		out.print(jo);
	}
	
	@SuppressWarnings("unchecked")
	@RequestMapping("/showInd")
	public void showInd(HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		Map<String,String> indMap1 = new LinkedHashMap<String,String>();
		indMap1.put("code", "01");
		indMap1.put("name","个人经营贷款");
		
		Map<String,String> indMap2 = new LinkedHashMap<String,String>();
		indMap2.put("code", "02");
		indMap2.put("name","个人消费贷款");
		
		Map<String,String> indMap3 = new LinkedHashMap<String,String>();
		indMap3.put("code", "03");
		indMap3.put("name","农户小额贷款");
		
		Map<String,String> indMap4 = new LinkedHashMap<String,String>();
		indMap4.put("code", "04");
		indMap4.put("name","信用卡专家");
		
		Map<String,String> indMap5 = new LinkedHashMap<String,String>();
		indMap5.put("code", "05");
		indMap5.put("name","住房按揭贷款");
		
		List<Map<String, String>> list = new ArrayList<Map<String,String>>();
		list.add(indMap1);
		list.add(indMap2);
		list.add(indMap3);
		list.add(indMap4);
		list.add(indMap5);
		
		JSONArray jo = JSONArray.fromObject(list);
		response.setContentType("application/json; charset=utf-8");  
		response.setHeader("Cache-Control", "no-cache");  
		 
		PrintWriter out = response.getWriter();
		 
		
		 out.print(jo);
	}
	
}
